var profitlist = {
    oTable: $('#table'),
    searchOk: $("#ok"),
    resetSearch: $("#reset"),
    init: function () {
        jeDate({
            dateCell: '#begin_at',
            format: 'YYYY-MM-DD',
            festival: true,
            maxDate: '2099-06-16 23:59:59', //最大日期
            isTime: true
        });
        jeDate({
            dateCell: '#end_at',
            format: 'YYYY-MM-DD',
            festival: true,
            maxDate: '2099-06-16 23:59:59', //最大日期
            isTime: true
        });
        this.initConfigTable();
    },
    initConfigTable: function () {
        var _self = this;
        this.oTable.bootstrapTable({
            url: "/finansys/ajaxprofitlist.html",
            method: 'post',
            contentType: "application/x-www-form-urlencoded",
            toolbar: '#toolbar',
            queryParams: this.queryParams,
            pagination: true, //是否分页
            pageSize: 20, //单页记录数
            pageList: [5, 10, 20, 50], //分页步进值
            sidePagination: "client", //服务端分页
            showFooter: true,
            responseHandler: function (data) {
                return data.rows;
            },
            columns: [
                {
                    title: "盈利类型",
                    field: "class_type",
                    valign: "middle", //垂直
                    footerFormatter: function () {
                        return "盈利总额";
                    }
                },
                {
                    title: "盈利金额",
                    field: "amount",
                    footerFormatter: function (data) {
                        var sum = 0;
                        for (var item in data) {
                            sum = sum + data[item].amount;
                        }
                        return sum.toFixed(2);
                    }
                },
//                {
//                    title: "备注",
//                    field: "description",
//                    valign: "middle"//垂直
//                },
                {
                    title: "盈利时间",
                    field: "created_at",
                    valign: "middle"//垂直
                }
            ]
        });
        this.searchOk.bind("click", function () {
            _self.oTable.bootstrapTable("refresh", {pagination: true});
        });
        this.resetSearch.bind("click", function () {
            $('#toolbar').find('input[name]').each(function () {
                $(this).val("");
            });
            $('#toolbar').find('select[name]').each(function () {
                $(this).val("");
                $('.selectpicker').selectpicker('val', '-1');
            });
            _self.oTable.bootstrapTable("refresh", {pagination: true});
        });
    },
    queryParams: function (params) {
        $('#toolbar').find('input[name]').each(function () {
            params[$(this).attr('name')] = $(this).val();
        });
        $('#toolbar').find('select[name]').each(function () {
            params[$(this).attr('name')] = $(this).val();
        });
        return params;
    }
};
var recharge = {
    oTable: $('#table'),
    searchOk: $("#ok"),
    resetSearch: $("#reset"),
    init: function () {
        jeDate({
            dateCell: '#begin_at',
            format: 'YYYY-MM-DD',
            festival: true,
            maxDate: '2099-06-16 23:59:59', //最大日期
            isTime: true
        });
        jeDate({
            dateCell: '#end_at',
            format: 'YYYY-MM-DD',
            festival: true,
            maxDate: '2099-06-16 23:59:59', //最大日期
            isTime: true
        });
        this.initConfigTable();
    },
    initConfigTable: function () {
        var _self = this;
        this.oTable.bootstrapTable({
            url: "/finansys/ajaxrechargelist.html",
            method: 'post',
            contentType: "application/x-www-form-urlencoded",
            toolbar: '#toolbar',
            queryParams: this.queryParams,
            pagination: true, //是否分页
            pageSize: 20, //单页记录数
            pageList: [5, 10, 20, 50], //分页步进值
            sidePagination: "client", //服务端分页
            showFooter: true,
            responseHandler: function (data) {
                return data.rows;
            },
            columns: [
                {
                    title: "订单编号",
                    field: "id",
                    footerFormatter: function () {
                        return "充值总额";
                    }
                },
                {
                    title: "商户账号",
                    field: "username"
                },
                {
                    title: "充值金额",
                    field: "amount",
                    footerFormatter: function (data) {
                        var sum = 0;
                        for (var item in data) {
                            sum = sum + data[item].amount;
                        }
                        return sum.toFixed(2);
                    }
                },
                {
                    title: "充值状态",
                    field: "status"
                },
                {
                    title: "充值时间",
                    field: "time",
                    valign: "middle"//垂直
                }
            ]
        });
        this.searchOk.bind("click", function () {
            _self.oTable.bootstrapTable("refresh", {pagination: true});
        });
        this.resetSearch.bind("click", function () {
            $('#toolbar').find('input[name]').each(function () {
                $(this).val("");
            });
            _self.oTable.bootstrapTable("refresh", {pagination: true});
        });
    },
    queryParams: function (params) {
        $('#toolbar').find('input[name]').each(function () {
            params[$(this).attr('name')] = $(this).val();
        });
        return params;
    }
};
var drawal = {
    oTable: $('#table'),
    searchOk: $("#ok"),
    resetSearch: $("#reset"),
    init: function () {
        jeDate({
            dateCell: '#begin_at',
            format: 'YYYY-MM-DD',
            festival: true,
            maxDate: '2099-06-16 23:59:59', //最大日期
            isTime: true
        });
        jeDate({
            dateCell: '#end_at',
            format: 'YYYY-MM-DD',
            festival: true,
            maxDate: '2099-06-16 23:59:59', //最大日期
            isTime: true
        });
        this.initConfigTable();
    },
    initConfigTable: function () {
        var _self = this;
        this.oTable.bootstrapTable({
            url: "/finansys/ajaxdrawallist.html",
            method: 'post',
            contentType: "application/x-www-form-urlencoded",
            toolbar: '#toolbar',
            queryParams: this.queryParams,
            pagination: true, //是否分页
            pageSize: 20, //单页记录数
            pageList: [5, 10, 20, 50], //分页步进值
            sidePagination: "client", //服务端分页
            showFooter: true,
            responseHandler: function (data) {
                return data.rows;
            },
            columns: [
                {
                    title: "刷手账号",
                    field: "username",
                    footerFormatter: function () {
                        return "提现总额";
                    }
                },
                {
                    title: "商户订单号",
                    field: "partner_trade_no"
                },
                {
                    title: "微信订单号",
                    field: "payment_no"
                },
                {
                    title: "提现金额",
                    field: "amount",
                    footerFormatter: function (data) {
                        var sum = 0;
                        for (var item in data) {
                            sum = sum + data[item].amount;
                        }
                        return sum.toFixed(2);
                    }
                },
                {
                    title: "微信支付成功时间",
                    field: "payment_time"
                }
            ]
        });
        this.searchOk.bind("click", function () {
            _self.oTable.bootstrapTable("refresh", {pagination: true});
        });
        this.resetSearch.bind("click", function () {
            $('#toolbar').find('input[name]').each(function () {
                $(this).val("");
            });
            _self.oTable.bootstrapTable("refresh", {pagination: true});
        });
    },
    queryParams: function (params) {
        $('#toolbar').find('input[name]').each(function () {
            params[$(this).attr('name')] = $(this).val();
        });
        return params;
    }
};
var tenantlist = {
    oTable: $('#table'),
    searchOk: $("#ok"),
    resetSearch: $("#reset"),
    init: function () {
        this.initConfigTable();
    },
    initConfigTable: function () {
        var _self = this;
        this.oTable.bootstrapTable({
            url: "/finansys/ajaxtenantlist.html",
            method: 'post',
            contentType: "application/x-www-form-urlencoded",
            toolbar: '#toolbar',
            queryParams: this.queryParams,
            pagination: true, //是否分页
            pageSize: 20, //单页记录数
            pageList: [5, 10, 20, 50], //分页步进值
            sidePagination: "client", //服务端分页
            responseHandler: function (data) {
                return data.rows;
            },
            columns: [
                {
                    title: "商户账号",
                    field: "username",
                    valign: "middle"
                },
                {
                    title: "描述",
                    field: "desc"
                },
                {
                    title: "金额",
                    field: "amount",
                    valign: "middle"//垂直
                },
                {
                    title: "类型",
                    field: "type",
                    valign: "middle"//垂直
                },
                {
                    title: "时间",
                    field: "time",
                    valign: "middle"//垂直
                }
            ]
        });
        this.searchOk.bind("click", function () {
            _self.oTable.bootstrapTable("refresh", {pagination: true});
        });
        this.resetSearch.bind("click", function () {
            $('#toolbar').find('input[name]').each(function () {
                $(this).val("");
            });
            $('#toolbar').find('select[name]').each(function () {
                $(this).val("");
                $('.selectpicker').selectpicker('val', '-1');
            });
            _self.oTable.bootstrapTable("refresh", {pagination: true});
        });
    },
    queryParams: function (params) {
        $('#toolbar').find('input[name]').each(function () {
            params[$(this).attr('name')] = $(this).val();
        });
        $('#toolbar').find('select[name]').each(function () {
            params[$(this).attr('name')] = $(this).val();
        });
        return params;
    }
};